﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Wix.Aura.Common;
using Wix.Aura.UnitTests.Tools;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.UnitTests.Common {
	[TestFixture]
	public class ShortcutSerialization {
		[SetUp]
		public void SetUp() {
			shortcut = new Shortcut("shortcut", new Aura.Common.CustomTypes.LongFileNameType("longFileName"));
		}

		Shortcut shortcut;

		[Test]
		public void EmptyShortCut() {
			XmlAssert.AreEqual(@"<Shortcut Id=""shortcut"" Name=""longFileName"" />", shortcut);
		}

		[Test]
		public void AllAttributes() {
			shortcut.Advertise = YesNoType.Yes;
			shortcut.Arguments = "arg-0";
			shortcut.Description = "description";
			shortcut.DescriptionResourceDll = "res.dll";
			shortcut.DescriptionResourceId = 1;
			shortcut.Directory = "directory";
			shortcut.DisplayResourceDll = "res2.dll";
			shortcut.DisplayResourceId = 2;
			shortcut.Hotkey = 3;
			shortcut.Icon = "Icon";
			shortcut.IconIndex = 4;
			shortcut.LongName = new LongFileNameType("longerFileName");
			shortcut.ShortName = new ShortFileNameType("shortFileName");
			shortcut.Show = Show.Maximized;
			shortcut.Target = "target";
			shortcut.WorkingDirectory = "C:\\working";

			XmlAssert.AreEqual(@"<Shortcut Id=""shortcut"" Name=""longFileName"" Advertise=""yes"" Arguments=""arg-0"" Description=""description"" DescriptionResourceDll=""res.dll"" 
DescriptionResourceId=""1"" Directory=""directory"" DisplayResourceDll=""res2.dll"" DisplayResourceId=""2"" Hotkey=""3"" Icon=""Icon"" IconIndex=""4"" LongName=""longerFileName"" 
ShortName=""shortFileName"" Show=""Maximized"" Target=""target"" WorkingDirectory=""C:\working"" />", shortcut);
		}

		[Test]
		public void ShortcutWithIcon() {
			shortcut.Icons.Add(new Icon("icon"));
			XmlAssert.AreEqual(@"<Shortcut Id=""shortcut"" Name=""longFileName"" ><Icon Id=""icon"" /></Shortcut>", shortcut);
		}

		[Test]
		public void ShortcutWithShortcutProperty() {
			shortcut.ShortcutProperty.Add(new ShortcutProperty("shortcut"));
			XmlAssert.AreEqual(@"<Shortcut Id=""shortcut"" Name=""longFileName"" ><ShortcutProperty Key=""shortcut"" /></Shortcut>", shortcut);
		}
	}
}
